package main

import (
	httptansport "github.com/go-kit/kit/transport/http"
	"github.com/gorilla/mux"
	"gokit_shizhan/Endpoint"
	"gokit_shizhan/Services"
	"gokit_shizhan/Transport"
	"net/http"
)
func main() {
	userService := Services.Service{}
	myendpoint := Endpoint.ServiceEndpointUser(userService)
	serviceHandler := httptansport.NewServer(myendpoint, Transport.DecodeUserRequest, Transport.EncodeUserRequest)

	r := mux.NewRouter()
	//r.Handle(`/user/{uid:\d+}`, serviceHandler)
	r.Methods("GET").Path(`/user/{uid:\d+}`).Handler(serviceHandler)
	r.Methods("GET").Path("/health").HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
		writer.Header().Set("Content-type", "application/json")
		writer.Write([]byte(`{"status":"ok"}`))
	})
	//Utils.RegService() //调用注册服务程序
	http.ListenAndServe(":8080", r)
}
